package org.liufeng.course.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.net.URL;

import javax.faces.application.Application;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;

import com.sun.xml.internal.ws.client.RequestContext;


public class WriteJsonYQ {
	public static void WriteJson(String line){
		
		String url = Thread.currentThread().getContextClassLoader().getResource("").getPath();
	//	String url = "D:\\Program Files (x86)\\Apache Software Foundation\\Tomcat 6.0\\webapps\\ROOT\\WEB-INF\\classes";
	    File file1 = new File(url); 
	    String path = file1.getParent().replace("%20", " ").toString()+"\\test.json";
	    System.out.print(path);
	    File file = new File(path); 
	    try {  
	    	if(!file.exists()){
		        file.createNewFile();
		       }
	        BufferedWriter writer  = new BufferedWriter(new FileWriter(file));  
	        writer.write(line);  
	        writer.flush();  
	        writer.close();  
	    } catch (Exception e) {  
	        e.printStackTrace();  
	    } 
	}
}
